function showNumberWithAnimation(i, j, randNumber){
	var numberCell = $('#number-cell-' + i + "-" + j);
	
	numberCell.css('background-color', getNumberBackgroundColor(randNumber));
	numberCell.css('color', getNumberColor(randNumber));
	numberCell.text(theKingText(randNumber));
	
	numberCell.animate({
		width:cellSideLength,
		height:cellSideLength,
		top:getPosTop(i, j),
		left:getPosLeft(i, j)
		
	}, 50);
}

function showMoveAnimation(fromx, fromy, tox, toy){
	var numberCell = $('#number-cell-' + fromx + '-' + fromy);
	numberCell.animate({
		top:getPosTop(tox, toy),
		left:getPosLeft(tox, toy)
	}, 200);
}

function updateScore(score){
	if(probability == 0.6){
		if(score > 3000){
			$("#score").css('color', 'red');
		}
		
		if(score > 3000 && isFirst){
		var wav0 = "./music/yuta02_03.wav";
		var wav0 = new Audio(wav0);
		wav0.volume = 1;
		wav0.play();
		isFirst = false;
		}
		else if(score > 12000 && firstMusic)
		{
			var wav1 = "./music/yuta02_01.wav";
			var wav1 = new Audio(wav1);
			wav1.play();
			firstMusic = false;
			}
	}
	
	else if(probability == 0.85){
		if(score > 2000){
			$("#score").css('color', 'red');
		}
		
		if(score > 2000 && isFirst){
		var wav0 = "./music/yuta02_03.wav";
		var wav0 = new Audio(wav0);
		wav0.volume = 1;
		wav0.play();
		isFirst = false;
		}
		else if(score > 10000 && firstMusic)
		{
			var wav1 = "./music/yuta02_01.wav";
			var wav1 = new Audio(wav1);
			wav1.play();
			firstMusic = false;
			}
	}
	
	else{
		if(score > 1500){
		$("#score").css('color', 'red');
	}
	
	if(score > 1500 && isFirst){
	var wav0 = "./music/yuta02_03.wav";
	var wav0 = new Audio(wav0);
	wav0.volume = 1;
	wav0.play();
	isFirst = false;
	}
	else if(score > 8000 && firstMusic)
	{
		var wav1 = "./music/yuta02_01.wav";
		var wav1 = new Audio(wav1);
		wav1.play();
		firstMusic = false;
		}
	}
	$('#score').text(score);
}

function theKingText(king){

	switch(king){
		case 2:
			return "黑铁";
			break;
		case 4:
			return "青铜";
			break;
		case 8:
			return "白银";
			break;
		case 16:
			return "黄金";
			break;
		case 32:
			return "铂金";
			break;
		case 64:
			return "钻石";
			break;
		case 128:
			return "大师";
			break;
		case 256:
			return "宗师";
			break;
		case 512:
			return "王者";
			break;
		case 1024:
			return "仙王";
			break;
		case 2048:
			return "神";
			break;
		case 4096:
			return "？？？";
			break;
		case 8196:
			return "这还是人吗？";
			break;
			
		default:
			break;
	}
	return "black";
}